package com.tuju.jetpackfirstdemo.ui.timer;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.Group;
import androidx.constraintlayout.widget.Placeholder;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.tuju.jetpackfirstdemo.R;
import com.tuju.jetpackfirstdemo.ui.recordings.RecordingActivity;

public class TimerSelectActivity extends AppCompatActivity {

    private Group groupA;
    private Placeholder place_hodler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_timer_select);
//        groupA = findViewById(R.id.group_a);
        place_hodler = findViewById(R.id.place_hodler);
    }

    public void grow(View view) {
        String str = ((TextView) view).getText().toString();
        str += "~~~~";
        ((TextView) view).setText(str);
    }

    public void showHide(View view) {
        groupA.setVisibility((groupA.getVisibility() == View.GONE) ? View.VISIBLE : View.GONE);

    }

    public void placeHolder(View view){
        place_hodler.setContentId(R.id.btn_old);
    }


    public void payComple(View view) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.JDialogStyle);
        View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_pay_comple, null);
        final AlertDialog alertDialog = builder.create();
        dialogView.findViewById(R.id.btn_sure).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.dismiss();
                Toast.makeText(TimerSelectActivity.this, "支付成功！", Toast.LENGTH_SHORT).show();
                paySuccess(null);
            }
        });
        dialogView.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.dismiss();
            }
        });
        alertDialog.setView(dialogView);
        alertDialog.show();
    }

    public void paySuccess(View view) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.JDialogStyle);
        View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_pay_success, null);
        final AlertDialog alertDialog = builder.create();
        dialogView.findViewById(R.id.btn_sure).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                alertDialog.dismiss();
            }
        });
        alertDialog.setView(dialogView);
        alertDialog.show();
    }
}
